package exercise.jslide.jslide.view.components;

import exercise.jslide.jslide.model.shapes.Shape;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;

public class ShapeView extends Canvas {
    private Shape shape;

    public ShapeView(Shape shape) {
        this.shape = shape;
        this.setWidth(shape.getWidth());
        this.setHeight(shape.getHeight());
        draw();
    }

    public void draw() {
        GraphicsContext gc = this.getGraphicsContext2D();
        shape.draw(gc);
    }

    public Shape getShape() {
        return shape;
    }

    public void setShape(Shape shape) {
        this.shape = shape;
        this.setWidth(shape.getWidth());
        this.setHeight(shape.getHeight());
        draw();
    }


}